from typing import Optional
import datetime

from pydantic import BaseModel, ConfigDict, Field
from pydantic.alias_generators import to_camel

from module_admin.annotation.pydantic_annotation import as_query


class FutureStrategyPositionModel(BaseModel):
    """
    期货策略仓位表对应pydantic模型
    """

    model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)

    id: Optional[int] = Field(default=None, description='仓位id')
    date: Optional[str] = Field(default=None, description='交易日期')
    strategy_instance: Optional[str] = Field(default=None, description='策略实例名称')
    position: Optional[float] = Field(default=0, description='总仓位')
    long_position: Optional[float] = Field(default=0, description='多仓')
    short_position: Optional[float] = Field(default=0, description='空仓')
    create_time: Optional[str] = Field(default=None, description='创建时间')
    update_time: Optional[str] = Field(default=None, description='更新时间')


@as_query
class FutureStrategyPositionQueryModel(FutureStrategyPositionModel):
    """
    期货策略仓位管理不分页查询模型
    """
    pass


@as_query
class FutureStrategyPositionPageQueryModel(FutureStrategyPositionQueryModel):
    """
    期货策略仓位管理分页查询模型
    """

    page_num: int = Field(default=1, description='当前页码')
    page_size: int = Field(default=10, description='每页记录数')


class DeleteFutureStrategyPositionModel(BaseModel):
    """
    删除期货策略仓位模型
    """

    ids: list[int] = Field(description='仓位id列表')